package com.bbc.action.shop;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.bbc.base.BaseAction;
import com.bbc.entity.shop.Shop;
import com.bbc.entity.shop.ShopQuery;
import com.bbc.service.shop.ShopService;

public class ShopAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	@Autowired
	private transient ShopService shopService;
	private Shop shop;
	private ShopQuery query;
	private List<Shop> shops;
	
	public String addShopFromTbaip() {
		if (shop == null) {
			shop = new Shop();
		}
		shopService.addShopFromTBApi(shop.getNick());
		return list();
	}
	
	public String list() {
		if (query == null) {
			query = new ShopQuery();
		}
		shops = shopService.findShop(query, page, 3);
		return SUCCESS;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	public ShopQuery getQuery() {
		return query;
	}

	public void setQuery(ShopQuery query) {
		this.query = query;
	}

	public List<Shop> getShops() {
		return shops;
	}

	public void setShops(List<Shop> shops) {
		this.shops = shops;
	}

}
